home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / prof / sun3.md / profStack.s < prev    next >
Text File  |  1989-02-14  |  3KB  |  113 lines

  1. /* 
  2.  * profStack.s --
  3.  *
  4.  * Procedures for managing stack traces.
  5.  *
  6.  * Prof_ThisFP --
  7.  *    Return the frame pointer of our caller.
  8.  *
  9.  * Prof_CallerFP --
  10.  *    Return the frame pointer of our caller's caller.
  11.  *    (mod, return frame pointer of our caller)
  12.  *
  13.  * Prof_NextFP --
  14.  *    Given a frame pointer, return the frame pointer to
  15.  *    the previous stack frame.
  16.  *
  17.  * Prof_ThisPC --
  18.  *    Given a frame pointer, return the PC from which this
  19.  *    frame was called.
  20.  *
  21.  *  $Header: /sprite/src/kernel/prof/sun3.md/RCS/profStack.s,v 8.1 89/02/14 10:34:40 brent Exp $ SPRITE (Berkeley)
  22.  *
  23.  * Copyright (C) 1985 Regents of the University of California
  24.  * All rights reserved.
  25.  */
  26.  
  27. #ifndef lint
  28. #endif not lint
  29.  
  30.  
  31. #if    defined(VAX) || defined(vax)
  32.     /*
  33.      * The calls instruction on the VAX updates the
  34.      * frame pointer, so we have to go back two levels
  35.      * on the stack.
  36.      */
  37.     .globl    _Prof_Whence
  38.     .globl    _Prof_NextFP
  39.     .globl    _Prof_ThisPC
  40. _Prof_Whence:
  41.     .word    0
  42.     movl    12(fp),r0    /* r0/ fp of caller */
  43.     movl    12(r0),r0    /* r0/ fp of caller's caller */
  44.     ret
  45.  
  46. _Prof_NextFP:
  47.     .word     0
  48.     movl    4(ap),r0    /* r0/ argument fp */
  49.     movl    12(r0),r0    /* r0/ previous fp */
  50.     ret
  51.  
  52. _Prof_ThisPC:
  53.     .word    0
  54.     movl    4(ap),r0    /* r0/ argument fp */
  55.     movl    16(r0),r0    /* r0/ pc with fp */
  56.     ret
  57. #endif    defined(VAX) || defined(vax)
  58.  
  59.  
  60. #if    defined(mc68000) || defined(sun2) || defined(sun3)
  61. |    .globl    _Prof_Whence
  62.     .globl    _Prof_NextFP
  63.     .globl    _Prof_ThisFP
  64.     .globl    _Prof_CallerFP
  65.     .globl    _Prof_ThisPC
  66. /*
  67.  * Prof_Whence, the stack looks like this when it gets called.
  68.  *    There is no link instruction so we are still using mcount's
  69.  *    (or whomever's) frame pointer.
  70.  *
  71.  *    a6 is the frame pointer register.
  72.  *
  73.  *     Bottom of the stack (it grows away from here)
  74.  *  |----------------------------|
  75.  *  | Args to Foo                |
  76.  *  |----------------------------|
  77.  *  | PC of jsr Foo              |
  78.  *  |----------------------------|
  79.  *  | Saved FP0                  |    <--  FP1     (Foo's frame)
  80.  *  |----------------------------|
  81.  *  | Saved registers            |
  82.  *  |----------------------------|
  83.  *  | PC of jsr mcount           |
  84.  *  |----------------------------|
  85.  *  | Saved FP1                  |    <--  FP2    (mcount's frame)
  86.  *  |----------------------------|
  87.  *  | Saved registers            |
  88.  *  |----------------------------|
  89.  *  | PC of jsr Prof_Whence      |
  90.  *  |----------------------------|    <--  SP
  91.  *  
  92.  */
  93. _Prof_ThisFP:
  94.     movl    a6,d0        /* just the frame pointer */
  95.     rts
  96.  
  97. _Prof_CallerFP:
  98. /*    movl    a6@,a0
  99.     movl    a0@,d0 */
  100.     movl    a6@,d0        /* just our caller's frame pointer */
  101.     rts
  102.  
  103. _Prof_NextFP:
  104.     movl    sp@(4),a0
  105.     movl    a0@,d0
  106.     rts
  107.  
  108. _Prof_ThisPC:
  109.     movl    sp@(4),a0
  110.     movl    a0@(4),d0
  111.     rts
  112. #endif    defined(mc68000) || defined(sun2)
  113.